<style type="text/css">
#preview_content{
    margin-top : 5px;
	border : 1px solid #C6C8C6;
    padding : 5px;
}
#previewText{
    font-size: 11pt;
}
</style>

<div class="create-form">
<?php //echo $this->form->render($this) ?>

<!-- <div id="image"></div>-->
<form id="<?php echo $this->form->getAttrib('id');?>" name="<?php echo $this->form->getAttrib('name');?>" enctype="multipart/form-data" action="<?php echo $this->escape($this->form->getAction()) ?>" method="<?php echo $this->escape($this->form->getMethod()) ?>" class="global_form">
    <div>
        <div>
            <h3>
                <?php echo $this->translate($this->form->getTitle()) ?>
            </h3>
            <p class="form-description"><?php //echo $this->translate($this->form->getDescription()) ?></p>
            <div class="form-elements">
                <?php echo $this->form->getDecorator('FormErrors')->setElement($this->form)->render("");?>
                <?php if($this->form->getDecorator('FormMessages')->getMessages()) echo $this->form->getDecorator('FormMessages')->setElement($this->form)->render('');?> 
                
                <?php echo $this->form->content; ?>
                
                <?php if($this->viewer->type == 'company'):?>
                <?php echo $this->form->duration; ?>
                <?php echo $this->form->pro_title; ?>
                <?php echo $this->form->pro_description; ?>
                <?php echo $this->form->ads_image; ?>
                <?php echo $this->form->ads_description; ?>
                <?php endif?>
                
                <?php echo $this->form->previewTangle; ?>
                <?php echo $this->form->preview; ?>
                <?php echo $this->form->buttons; ?>
            </div>
         </div>
    </div>
</form> 
</div>

<script type="text/javascript">

function openAdsform(){
        var href = en4.core.baseUrl + 'talktangle/ads/create';
        this.location.href = href;
}
en4.core.runonce.add(function() {
    
    var preview = new Element('div', {
        'id' : 'preview_content',
        styles : {
            'display' : 'none',
        }
    }).inject($('previewTangle'),'after');    
    
    var preview_text = new Element('div', {
            'id' : 'previewText',
            }).inject($('preview_content'));      
    });

    function previewTalktangle(){
        request = new Request.JSON({
              url : en4.core.baseUrl + 'talktangle/ajax/previewtalktangle',
              data : {
                format : 'json',
                content : $('content').get('value')
              },
              onRequest: function(){
                $('previewText').set('html', '<img src="'+ en4.core.baseUrl + 'application/modules/Core/externals/images/loading.gif' +'">');
              },
              onComplete: function(response) {
                  $('previewText').set('html', response);
                  $('preview').set('value', response);
                  $('preview_content').setStyles({'display': 'block'});
               }
            });
            request.send();
            
    }    

    
</script>